package com.coin900.coin.cmd.system_config;

import com.coin900.coin.cmd.ACmd;
import com.coin900.coin.cmd.CmdSign;
import com.coin900.coin.code.CmdCode;
import com.coin900.coin.persist.fu.FuUserVO;
import com.coin900.coin.persist.sbi.SbiSystemConfigVO;
import com.coin900.coin.service.sbi.ISbiSystemConfigService;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * 添加项目
 *
 * @author shui
 * @create 2017-11-28
 **/
@Controller
public class SystemConfigPostCmd extends ACmd {

    @Override
    public CmdSign execute(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        FuUserVO user = super.getUser(sign);
        String source = sign.getSource();
        SbiSystemConfigVO configVO = new Gson().fromJson(source, SbiSystemConfigVO.class);
        configVO.setCreatedInfor(user);
        this.systemConfigService.insertSbiSystemConfig(configVO);
        return respSign;
    }

    @Autowired
    private ISbiSystemConfigService systemConfigService;

    @Override
    public String getCmdCode() {
        return CmdCode.SYSTEM_CONFIG_POST;
    }
}
